import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '../views/Login/index.vue'
import Layout from '../views/Layout/index.vue'
import Console from '../views/Console/index.vue'
import InfoList from '../views/InfoList/index.vue'
import InfoCate from '../views/InfoCate/index.vue'
import UserList from '../views/UserList/index.vue'
import InfoDetail from '../views/infoDetail/index.vue'
import Page404 from '../views/404Page.vue'
Vue.use(VueRouter)

export const defaultRoutes = [
  {
    path: '/',
    redirect: '/login',
    meta: {
      label: '',
      hidden: true
    }
  },
  {
    path: '/login',
    component: Login,
    meta: {
      label: '登录',
      hidden: true
    }
  },
  {
    path: '/home',
    component: Layout,
    redirect: '/console',
    meta: {
      label: '控制台',
      hidden: false,
      icon: 'el-icon-stopwatch'
    },
    children: [{
      path: '/console',
      component: Console,
      meta: {
        label: '控制台'
      }
    }]
  },
  {
    path: '/home',
    component: Layout,
    meta: {
      label: '404',
      hidden: true
    },
    children: [{
      path: '/page404',
      component: Page404
    }]
  }
]
//  technician sale manager
// ['manager', 'sale]
export const dynamicRoutes = [{
  path: '/home',
  component: Layout,
  meta: {
    label: '信息管理',
    hidden: false,
    icon: 'el-icon-document',
    system: 'info',
    role: ['technician', 'manager']
  },
  children: [{
    path: '/infolist',
    component: InfoList,
    meta: {
      label: '信息列表',
      role: ['technician', 'manager'],
      keepAlive: true
    }
  },
  {
    path: '/infocate',
    component: InfoCate,
    meta: {
      label: '信息分类',
      role: ['technician'],
      keepAlive: true
    }
  },
  {
    path: '/infodetail/:id',
    props: true,
    component: InfoDetail,
    meta: {
      label: '信息详情',
      hidden: true,
      role: ['technician'],
      keepAlive: true
    }
  }]
},
{
  path: '/home',
  component: Layout,
  meta: {
    label: '用户管理',
    hidden: false,
    icon: 'el-icon-user',
    system: 'user',
    role: ['manager', 'sale']
  },
  children: [{
    path: '/userlist',
    component: UserList,
    meta: {
      label: '用户列表',
      role: ['manager', 'sale'],
      keepAlive: true
    }
  }]
}, {
  path: '*',
  redirect: '/page404',
  meta: {
    hidden: true
  }
}]
const router = new VueRouter({
  routes: defaultRoutes
})

export default router
